import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'

// 密钥对生成 http://web.chacuo.net/netrsakeypair

const publicKey = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCykPCrvqhgG9vR7pW29xObvHv6aD1A+3hiwfkEkkT1PsI0VL0HgZo3H6u0wqzar7k09yekMZivFxXLMmSOhhh6/P10FGVEoML4k8sEQs/T7VV5ood162jEXkk5GrEoqHO2Cx5bmTB2KqW6D5yhrjqdSv7GT9/fEBlfsYVVvgjniQIDAQAB'

const privateKey = 'MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBALKQ8Ku+qGAb29Hulbb3E5u8e/poPUD7eGLB+QSSRPU+wjRUvQeBmjcfq7TCrNqvuTT3J6QxmK8XFcsyZI6GGHr8/XQUZUSgwviTywRCz9PtVXmih3XraMReSTkasSioc7YLHluZMHYqpboPnKGuOp1K/sZP398QGV+xhVW+COeJAgMBAAECgYAk4NhDsBGYH8jLV4nmCqsrC8dTFPoplIXtZ4AlWIwTVk3HfwS3KyYNYmYU4+vNEmOes7ilKXUOHCdtGtA3uywMybBknYJk8R5jAwkfffZiCJaGE60II9wdKd/7jf99LPtXCxFcUJ25lHQK/BEfzzAGLti9Zb0CxlUS4aDBQS3X7QJBAO0JmYmHzSNF8UT43In0SOm5+Q53wWALKAMdM0VUpEnxDovl1joyBRCnnKbbZ/i+tWxVGIjaCQOW63WhT246fC8CQQDA2eEM+UytoxS1uqKasTa3G+V2IzCo3djEdokYsbO9WpzvbfIR4Y54s6lQPYLcshsl2zWz6Xl1bZGrbtrn0NHHAkBfhzrlfmFiEdIGZfUbc+PeriB9gC3isxxRBPegvVfopMmj/+CyW25HJAWyCUKBsPoUysa0gIqZc705DuWgGtnpAkEAuc2xvLQ8olarT2Pf4ja3RrhD3gyNh0Um4jJqaDZdvCQfa7d8MKomgDho+nwpJsUazuBi31IkyXSlkowdsJdKZQJAbh71JgRcrqggr0f8uXwzbrDTUM2hywO51euZTBPHTij0OnVlS+qhLcvcRnWYaQX5FCvuoX/AHSeNfozcb/aFjQ=='

// 加密
export function encrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPublicKey(publicKey) // 设置公钥
  return encryptor.encrypt(txt) // 对数据进行加密
}

// 解密
export function decrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPrivateKey(privateKey) // 设置私钥
  return encryptor.decrypt(txt) // 对数据进行解密
}

